using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Framework.Singleton
{
    public class Singleton<T> where T : class
    {
        private static T instance;
        private static readonly object _lock = new object();

        public static bool IsEnable => instance != null;
        
        public static T Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (_lock)
                    {
                        if (instance == null)
                        {
                            instance = Activator.CreateInstance<T>();
                        }
                    }
                }

                return instance;
            }
        }
    }
}
